import BuffUtil from '@/BuffUtil';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 猪猪不怕
 **/
export default class BossSpell_PigDontScare extends AbilityBase {
    static instance: BossSpell_PigDontScare;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_PigDontScare',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        targetAttach: 'foot',
        targetArt: 'AbilitiesSpellsNightElfThornsAuraThornsAura.mdl',
        dur: 8,
    };
    constructor(id: string = 'Mzt1') {
        super(id);
        BossSpell_PigDontScare.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
        EventManager.onTakeDamage(this.onTakeAttack.bind(this));
    }
    onTakeAttack(d: DamageEventData) {
        if (d.isReflect) return;
        if (!BuffUtil.hasUnitBuff(d.target, this.buffType.id)) return;
        DamageSystemInstance.applyReflectDamage(d.source, d.target, d.lastDamage * 3, null);
        DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\NightElf\\ThornsAura\\ThornsAura.mdl', d.source, 'overhead'));
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BossAbilityManagerInstance.text('猪猪不怕', source);
        BuffUtil.addBuff(source, this.buffType.id, source);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
